package com.bite.friend.Controller;

import com.bite.friend.DTO.ExamListDTO;
import com.bite.friend.Service.ExamService;
import domain.MyThreadLocal;
import domain.R;
import domain.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/exam")
/**
 * 竞赛模块
 */
public class ExamController {

    @Autowired
    private ExamService examService;


    /**
     * 竞赛列表
     * @param examListDTO
     * @return
     */
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(ExamListDTO examListDTO){
        return examService.list(examListDTO);
    }


    /**
     * 竞赛列表(Redis版本)
     * @param examListDTO
     * @return
     */
    @GetMapping("/semiLogin/redis/list")
    public TableDataInfo listRedis(ExamListDTO examListDTO){
        String userId = MyThreadLocal.get();
        return examService.listRedis(examListDTO);
    }

    /**
     * 获取竞赛题目id
     * @param examId
     * @return
     */
    @GetMapping("/getExamQuestionId")
    public R<String> getExamQuestionId(long examId){
        return examService.getExamQuestionId(examId);
    }

    /**
     * 获取当前竞赛题目的上一个题目id
     */
    @GetMapping("/getPreviousQuestionId")
    public R<String> getPreviousQuestionId(long examId, long questionId){
        return examService.getPreviousQuestionId(examId, questionId);
    }

    /**
     * 获取当前竞赛题目的下一个题目id
     * @param examId
     * @param questionId
     * @return
     */
    @GetMapping("/getNextQuestionId")
    public R<String> getNextQuestionId(long examId, long questionId){
        return examService.getNextQuestionId(examId, questionId);
    }















}
